package com.gitee.feizns.quickstart.mybatis.flex.query;


import com.gitee.feizns.quickstart.domain.page.PageRecordsVo;
import com.gitee.feizns.quickstart.domain.page.PageVo;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;

import java.util.List;

/**
 * @author feizns
 * @since 2025/8/6
 */
@RequiredArgsConstructor
public class PageInfoPageRecordsVoImpl<T> implements PageRecordsVo<T> {

    /**
     * 分页参数信息
     */
    private final PageInfo<T> pageInfo;

    @Override
    public PageVo getPage() {
        return new PageVo() {
            @Override
            public Long getSize() {
                return (long) pageInfo.getPageSize();
            }
            @Override
            public Long getPages() {
                return (long) pageInfo.getPages();
            }
            @Override
            public Long getCurrent() {
                return (long) pageInfo.getPageNum();
            }
            @Override
            public Long getTotal() {
                return pageInfo.getTotal();
            }
        };
    }

    @Override
    public List<T> getRecords() {
        return pageInfo.getList();
    }

}
